package com.swinboo.im.entity.repository;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.util.Date;
import java.util.List;

/**
 * @author Swinboo
 * @date 2022-03-20 10:51
 * @description:
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
@Document(collection = "chat_record")
public class ChatRecord {


    public static String DOCUMENT_NAME = "chat_record";
    public static String RECORD_LIST = "recordList";
    @Id
    private String id;
    @Field
    private String u1;
    @Field
    private String u2;
    @Field
    private Integer u1UnreadCount;
    @Field
    private Integer u2UnreadCount;
    @Field
    private Integer count;
    @Field
    private Date lastTime;
    @Field
    private List<RecordItem> recordList;

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    public static class RecordItem {
        private String id;
        private String from;
        private String to;
        private MsgBody msgBody;
        private Date sendTime;
        private Boolean u1Deleted;
        private Boolean u2Deleted;

        @Data
        @AllArgsConstructor
        @NoArgsConstructor
        public static class MsgBody {
            private String msgType;
            private String msgContent;
        }
    }
}
